/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.*;

/**
 * @author DoanMinhVu
 */
public class MidletDuaXe extends MIDlet {

    private MenuGame menuGame;
    private PlayGameCanvas gameCanvas;
    private Help help;
    public List lst;
    public Exit exit;
    private Display display;
    private boolean isLoadIntro = true;

    public Display getDisplay() {
        return display;
    }

    public MidletDuaXe() {
        display = Display.getDisplay(this);
        Form frm = new Form("gewgew");
    }

    public void startApp() {
         showMenuGame();
        if(isLoadIntro){
            isLoadIntro = false;
            LoadIntro loadIntro = new LoadIntro(display, menuGame, 3000);
            loadIntro.starIntro();
         }
       
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        notifyDestroyed();
    }

    public void showMenuGame() {
        //gameCanvas = null;
        if(menuGame == null)
            menuGame = new MenuGame(this, display);
        display.setCurrent(menuGame);
    }

    public void showPlayGame() {
        menuGame = null;
        if(gameCanvas == null)
            gameCanvas = new PlayGameCanvas(this);
        gameCanvas.Start();
        display.setCurrent(gameCanvas);
    }

    public void showOption() {
    }

    public void showHighScore() {
        menuGame = null;
        //gameCanvas = null;
        HighScore higtScore = new HighScore(this,display);
        display.setCurrent(higtScore);
//        highScore = new HightScore();
//        display.setCurrent(highScore);
        // FileManager manager = new FileManager("HighScore.txt");
        //String options[] = manager.ReadLineString();
        //lst = new List("High Score:", List.IMPLICIT, options, null);
        //display.setCurrent(lst);
    }

    public void showHelp() {
        menuGame = null;
        //gameCanvas = null;
        if(help == null)
            help = new Help(this, display);
        display.setCurrent(help);
    }
     public void showExit(){
        menuGame = null;
        gameCanvas = null;
        exit = new Exit(this, display);
        display.setCurrent(exit);
    }

    public void commandAction(Command c, Displayable d) {
        throw new UnsupportedOperationException("Not supported yet.");
    }    
}
